<template>
    <div>
        <div class="app-container" v-loading="data.mtloading">
            <el-table :data="data.list" :header-cell-style="{ 'text-align': 'center' }"
                :cell-style="{ 'text-align': 'center' }" class="w-full">
                <el-table-column prop="s_id" label="ID" show-overflow-tooltip />
                <el-table-column prop="content" :label="$t('system.suggestions.feedback')" show-overflow-tooltip>
                    <template #default="scope">
                        <el-icon :color="scope.row.content ? '#409eff' : ''" @click="onContent(scope.row)">
                            <Document />
                        </el-icon>
                    </template>
                </el-table-column>
                <el-table-column prop="pic" :label="$t('presets.view.uploadPic')" show-overflow-tooltip />
                <el-table-column prop="email" :label="$t('account.account.mail')" show-overflow-tooltip />
                <el-table-column prop="creator_nickname" :label="$t('system.suggestions.presenter')"
                    show-overflow-tooltip />
                <el-table-column prop="create_time" :label="$t('date.createTime')" show-overflow-tooltip>
                    <template #default="scope">
                        {{ getPlevel.gettime(scope.row.create_time, 3) }}
                    </template>
                </el-table-column>
            </el-table>
            <PageNum :total="data.total" :page="data.info" @exposeData="current" @fraction="fraction" />
        </div>
        <el-dialog v-model="dialogContent" :title="$t('system.suggestions.feedback')" center width="30%">
            <div v-html="data.content" class="border p-5">
            </div>
        </el-dialog>
    </div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n'
const { t: $t } = useI18n()
import PageNum from '@/components/PageNum/index.vue';
import getPlevel from '@/utils/level'
import { getsuggestList } from '@/api/system';
let dialogContent = ref(false)
let data = reactive({
    content: '',
    mtloading: false,
    list: [],
    info: { // 筛选数据
        pageNum: 15,
        page: 1,
    },
    total: 0, // 总条数
})
let onContent = (row: any) => {
    if (row.content) {
        dialogContent.value = true
        data.content = row.content
    }
}
// 查询列表
let getlist = () => {
    data.mtloading = true
    getsuggestList(data.info).then(res => {
        data.mtloading = false
        if (res.state == 200) {
            data.list = res.data.data
            data.total = res.data.total
        }
    })
}
// 页数回调
let current = (e) => {
    data.info.page = e
    getlist()
}

// 条数回调
let fraction = (e) => {
    data.info.pageNum = e
    getlist()
}
getlist()
</script>
<style lang="scss" scoped>
.el-textarea__inner {
    min-height: 300px !important;
}
</style>